package com.hermes.action.json;

import com.hermes.biz.common.model.item.ItemDO;
import com.hermes.biz.common.util.json.JsonDataParserUtil;
import com.hermes.biz.common.util.string.StringUtil;
import com.hermes.biz.service.item.ItemService;
import com.hermes.common.action.AsynBaseAction;
import com.hermes.common.util.ParameterParserUtil;

public class AsynGetItemComments extends AsynBaseAction {

    /**
     *异步获取宝贝评论信息
     */
    private static final long serialVersionUID = -2978061461738963646L;

    private String            constent;

    private ItemService       itemService;

    @Override
    public String execute() {

        String itemIdStr = ParameterParserUtil.getParameter("itemId");

        long itemId = 0;

        if (StringUtil.isNumOnly(itemIdStr)) {
            itemId = Long.parseLong(itemIdStr);
        }

        ItemDO item = itemService.getSingleItemByItemId(itemId).getModule();
        if (item == null) {
            constent = "{}";
        }

        constent = JsonDataParserUtil.parse(item);

        return SUCCESS;
    }

    public void setItemService(ItemService itemService) {
        this.itemService = itemService;
    }

    public String getConstent() {
        return constent;
    }

    public void setConstent(String constent) {
        this.constent = constent;
    }

}
